package com.chainofresponsibility.pattern.service.handler.impl;

import com.chainofresponsibility.pattern.domain.AuditInfo;
import com.chainofresponsibility.pattern.service.AuditService;
import com.chainofresponsibility.pattern.service.handler.AuditHandler;

import java.util.Date;

/**
 * @author cc
 * @classname Level1AuditHandler
 * @description TODO
 * @date 2022/3/29 15:31
 */
public class Level1AuditHandler extends AuditHandler {

    public Level1AuditHandler(String levelUserId, String levelUserName) {
        super(levelUserId, levelUserName);
    }

    @Override
    public AuditInfo doAudit(String uid, String orderId, Date auditDate) {
        Date date = AuditService.queryAuditInfo(levelUserId, orderId);
        if (null == date) {
            System.out.println("待⼀级审批 负责⼈" + levelUserName);
            return new AuditInfo("0001", "单号：", orderId, " 状态：待⼀级审批 负责⼈：", levelUserName);
        }
        AuditHandler next = super.next();
        if (next == null) {
            System.out.println("级审批完成 审批⼈" + levelUserName);
            return new AuditInfo("0000", "单号：", orderId, " 状态：⼀级审批完成", " 时间：", sdf.format(date), " 审批⼈：", levelUserName);
        }
        return next.doAudit(uid, orderId, auditDate);
    }
}
